﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sinacor.UI.Bovespa.Ordens.Communication.Bovespa.Ordens.Motivo;
using Sinacor.Infra.UI.Common;

namespace Sinacor.UI.Bovespa.Ordens.Communication.Translator.ModelToDataContract
{
    public static class Motivo
    {
        public static FiltroMotivoRequest ToFiltroMotivoRequest(Model.Parameter.FiltroMotivo request)
        {
            FiltroMotivoRequest to = null;
            if (request != null)
            {
                to = new FiltroMotivoRequest();

                to.Codigo = request.Codigo;
                to.Descricao = request.Descricao;
            }

            return to;
        }

        public static List<FiltroMotivoRequest> ToFiltroMotivoRequest(ModelCollection<Model.Parameter.FiltroMotivo> request)
        {
            List<FiltroMotivoRequest> to = null;

            if (request != null)
            {
                to = new List<FiltroMotivoRequest>();
                foreach (Model.Parameter.FiltroMotivo item in request)
                    to.Add(ToFiltroMotivoRequest(item));
            }

            return to; 
        }

        public static MotivoRequest ToMotivoRequest(Model.Motivo request)
        {
            MotivoRequest to = null;
            if (request != null)
            {
                to = new MotivoRequest();

                to.Codigo = request.Codigo;
                to.Descricao = request.Descricao;
            }

            return to;
        }

        public static List<MotivoRequest> ToMotivoRequest(ModelCollection<Model.Motivo> request)
        {
            List<MotivoRequest> to = null;

            if (request != null)
            {
                to = new List<MotivoRequest>();
                foreach (Model.Motivo item in request)
                    to.Add(ToMotivoRequest(item));
            }

            return to; 
        }
    }
}
